CREATE EXTENSION dummy_seclabel;
SET client_min_messages TO 'warning';
DROP ROLE IF EXISTS regress_dummy_seclabel_user1;
DROP ROLE IF EXISTS regress_dummy_seclabel_user2;
RESET client_min_messages;
CREATE USER regress_dummy_seclabel_user1 WITH CREATEROLE;
CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS SELECT 4 language sql;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
ALTER TABLE dummy_seclabel_tbl2 OWNER TO regress_dummy_seclabel_user2;
SET SESSION AUTHORIZATION regress_dummy_seclabel_user1;
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'classified';
			SECURITY LABEL ON COLUMN dummy_seclabel_tbl1.a IS 'unclassified';
		SECURITY LABEL ON COLUMN dummy_seclabel_tbl1 IS 'unclassified';
	SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS '...invalid label...';
	SECURITY LABEL FOR 'dummy' ON TABLE dummy_seclabel_tbl1 IS 'unclassified';
	SECURITY LABEL FOR 'unknown_seclabel' ON TABLE dummy_seclabel_tbl1 IS 'classified';
	SECURITY LABEL ON TABLE dummy_seclabel_tbl2 IS 'unclassified';
	SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'secret';
		SECURITY LABEL ON TABLE dummy_seclabel_tbl3 IS 'unclassified';
	SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
	SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'unclassified';
		SECURITY LABEL ON TABLE dummy_seclabel_tbl2 IS 'classified';
			SET SESSION AUTHORIZATION regress_dummy_seclabel_user1;
			SET SESSION AUTHORIZATION regress_dummy_seclabel_user1;
SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS 'classified';
			SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS '...invalid label...';
	SECURITY LABEL FOR 'dummy' ON ROLE regress_dummy_seclabel_user2 IS 'unclassified';
	SECURITY LABEL FOR 'unknown_seclabel' ON ROLE regress_dummy_seclabel_user1 IS 'unclassified';
	SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS 'secret';
	SECURITY LABEL ON ROLE regress_dummy_seclabel_user3 IS 'unclassified';
	SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
	SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
SECURITY LABEL ON ROLE regress_dummy_seclabel_user2 IS 'unclassified';
	RESET SESSION AUTHORIZATION;
	RESET SESSION AUTHORIZATION;
RESET SESSION AUTHORIZATION;
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'top secret';
			SECURITY LABEL ON VIEW dummy_seclabel_view1 IS 'classified';
			SECURITY LABEL ON FUNCTION dummy_seclabel_four() IS 'classified';
		SECURITY LABEL ON DOMAIN dummy_seclabel_domain IS 'classified';
		CREATE SCHEMA dummy_seclabel_test;
		CREATE SCHEMA dummy_seclabel_test;
SECURITY LABEL ON SCHEMA dummy_seclabel_test IS 'unclassified';
		SET client_min_messages = error;
		SET client_min_messages = error;
CREATE PUBLICATION dummy_pub;
CREATE SUBSCRIPTION dummy_sub CONNECTION '' PUBLICATION foo WITH (connect = false, slot_name = NONE);
RESET client_min_messages;
SECURITY LABEL ON PUBLICATION dummy_pub IS 'classified';
SECURITY LABEL ON SUBSCRIPTION dummy_sub IS 'classified';
SELECT objtype, objname, provider, label FROM pg_seclabels	ORDER BY objtype, objname;
CREATE FUNCTION event_trigger_test()RETURNS event_trigger AS   BEGIN RAISE NOTICE 'event %: %', TG_EVENT, TG_TAG;
 END;
 END;
 LANGUAGE plpgsql;
CREATE EVENT TRIGGER always_start ON ddl_command_startEXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_end ON ddl_command_endEXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_drop ON sql_dropEXECUTE PROCEDURE event_trigger_test();
CREATE EVENT TRIGGER always_rewrite ON table_rewriteEXECUTE PROCEDURE event_trigger_test();
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'classified';
DROP EVENT TRIGGER always_start, always_end, always_drop, always_rewrite;
DROP VIEW dummy_seclabel_view1;
DROP TABLE dummy_seclabel_tbl1, dummy_seclabel_tbl2;
DROP SUBSCRIPTION dummy_sub;
DROP PUBLICATION dummy_pub;
DROP ROLE regress_dummy_seclabel_user1;
DROP ROLE regress_dummy_seclabel_user2;
